home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-30 | 2.1 KB | 93 lines | [TEXT/CWIE] |
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- //
- // AXInitialize.c
- //
- // >>> ⌐ 1996-1997 Microsoft Corporation. All rights reserved. <<<
- //
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- #include "AXContainerHeaders.h"
-
- #include <Threads.h>
- #include <ActiveXThreads.h>
- #include "CMacThreadManager.h"
- #include "urlapi.h"
-
- #include "AXInitialize.h"
-
- IMacThreadManager* gMacThreadManager = NULL;
-
- static Boolean8 ComInitialized = false;
- static Boolean8 UrlMonInitialized = false;
-
- //------------------------------------------------------------------------------------
- // InitActiveX
- //------------------------------------------------------------------------------------
- //
- AXErrorCode InitActiveX(void)
- {
- AXErrorCode theResult = NOERROR;
-
- // if we're already initialized, just return
- if ( !ComInitialized )
- {
- // Make sure COM is around
- if ( CoInitialize == (long) kUnresolvedCFragSymbolAddress )
- theResult = E_UNEXPECTED;
- else
- {
- // if we can get COM initialized, proceed
- if ( CoInitialize(NULL) == NOERROR )
- {
- ComInitialized = true;
-
- gMacThreadManager = (IMacThreadManager*) new CMacThreadManager();
-
- if ( gMacThreadManager )
- {
- if ( OpenUrlMoniker == (long) kUnresolvedCFragSymbolAddress )
- theResult = E_UNEXPECTED;
- else
- {
- if ( OpenUrlMoniker(gMacThreadManager) != noErr )
- theResult = E_FAIL;
- else
- UrlMonInitialized = true;
- }
- }
- else
- theResult = E_OUTOFMEMORY;
- }
- else
- theResult = E_FAIL;
- }
- }
-
- return theResult;
- }
-
-
- //------------------------------------------------------------------------------------
- // ExitActiveX
- //------------------------------------------------------------------------------------
- //
- void ExitActiveX(void)
- {
- if ( UrlMonInitialized )
- {
- CloseUrlMoniker();
- UrlMonInitialized = false;
- }
-
- if ( gMacThreadManager )
- {
- gMacThreadManager->Release();
- gMacThreadManager = NULL;
- }
-
- if ( ComInitialized )
- {
- CoUninitialize();
- ComInitialized = false;
- }
- }